let ul = document.querySelector("nav div ul")
let uls = document.querySelector("section ul")

const xhr1 = new XMLHttpRequest()
xhr1.open("get","http://chst.vip:1234/api/getbaicaijiatitle")
xhr1.onload = function(){
    if(xhr1.status === 200){
        let res1 = JSON.parse(xhr1.responseText)
        // console.log(res1)
        let resru = res1.result
        // console.log(resru)
        lis = ''

        resru.forEach((item,index) => {
            lis += `
        <li titleId = ${item.titleId}>${item.title}</li>
        `
            
        });
        ul.innerHTML = lis

        
    }
}
xhr1.send(null)




const xhr2 = new XMLHttpRequest()
xhr2.open("get",`http://chst.vip:1234/api/getbaicaijiaproduct?titleid=0`)
xhr2.onload = function(){
    if(xhr2.status === 200 ){
        let res2 = JSON.parse(xhr2.responseText)
        // console.log(res2)
        let res2r = res2.result
        console.log(res2r)

        let divs = ''

        res2r.forEach((itemm,indexx)=>{
            divs +=`
            <li>
            
                    

                        <div class="left">
                            ${itemm.productImg}
                        </div>


                        <div class="right">
                            <div class="righto">
                                <h4>${itemm.productName}</h4>
                                <div>${itemm.productPrice}<del>1888</del></div>
                                
                            </div>
                            <div class="rightr"></div>
                            <div class="rights">
                                <p>${itemm.productCoupon}</p>
                                <p>${itemm.productHref}</p>
                            </div>
                        </div>
                    
                
            </li>
            `
        })
        uls.innerHTML = divs
    }
}
xhr2.send(null)